MkConfigSetting
Node for describing a config setting.
Examples
Example: YAML format
Note
Jinja
{{ "path" | MkConfigSetting(mode="yaml", setting={"plugins": {"mknodes": {"path": "path.to.module"}}}, description="Some **markdown** to describe the setting", default="path.to.module")}}
Note
Python
MkConfigSetting( "path", "Some **markdown** to describe the setting", setting={"plugins": {"mknodes": {"path": "path.to.module"}}}, default="path.to.module", )
Rendered
**path**-
Default:
'path.to.module'Some markdown to describe the setting
plugins: mknodes: path: path.to.module
Markdown
`**path**`
: Default: `'path.to.module'`
Some **markdown** to describe the setting
````yaml
plugins:
mknodes:
path: path.to.module
````
Html
<p><code>**path**</code>
: Default: <code>'path.to.module'</code></p>
<pre><code>Some **markdown** to describe the setting
````yaml
plugins:
mknodes:
path: path.to.module
````
</code></pre>
Repr tree
MkConfigSetting
╰── MkCode(None, language='yaml')
╰── MkText('plugins:\n mknodes:\n path: path.to.module\n')
Example: JSON format
Note
Jinja
{{ "path" | MkConfigSetting(mode="json", setting={"plugins": {"mknodes": {"path": "path.to.module"}}}, description="Some **markdown** to describe the setting", default="path.to.module")}}
Note
Python
MkConfigSetting( "path", "Some **markdown** to describe the setting", setting={"plugins": {"mknodes": {"path": "path.to.module"}}}, default="path.to.module", mode="json", )
Rendered
**path**-
Default:
'path.to.module'Some markdown to describe the setting
{ "plugins": { "mknodes": { "path": "path.to.module" } } }
Markdown
`**path**`
: Default: `'path.to.module'`
Some **markdown** to describe the setting
````json
{
"plugins": {
"mknodes": {
"path": "path.to.module"
}
}
}
````
Html
<p><code>**path**</code>
: Default: <code>'path.to.module'</code></p>
<pre><code>Some **markdown** to describe the setting
````json
{
"plugins": {
"mknodes": {
"path": "path.to.module"
}
}
}
````
</code></pre>
Repr tree
MkConfigSetting
╰── MkCode(None, language='json')
╰── MkText('{\n "plugins": {\n "mknodes": {\n "path": "path.to.module"\n }\n }\n}')
Example: TOML format
Note
Jinja
{{ "path" | MkConfigSetting(mode="toml", setting={"plugins": {"mknodes": {"path": "path.to.module"}}}, description="Some **markdown** to describe the setting", default="path.to.module")}}
Note
Python
MkConfigSetting( "path", "Some **markdown** to describe the setting", setting={"plugins": {"mknodes": {"path": "path.to.module"}}}, default="path.to.module", mode="toml", )
Rendered
**path**-
Default:
'path.to.module'Some markdown to describe the setting
[plugins.mknodes] path = "path.to.module"
Markdown
`**path**`
: Default: `'path.to.module'`
Some **markdown** to describe the setting
````toml
[plugins.mknodes]
path = "path.to.module"
````
Html
<p><code>**path**</code>
: Default: <code>'path.to.module'</code></p>
<pre><code>Some **markdown** to describe the setting
````toml
[plugins.mknodes]
path = "path.to.module"
````
</code></pre>
Repr tree
MkConfigSetting
╰── MkCode(None, language='toml')
╰── MkText('[plugins.mknodes]\npath = "path.to.module"\n')
Base classes
| Name | Children | Inherits |
|---|---|---|
| MkTemplate mknodes.templatenodes.mktemplate Node representing a jinja template. |
⋔ Inheritance diagram
graph TD
1561279813["mkconfigsetting.MkConfigSetting"]
1289759389["mktemplate.MkTemplate"]
3160803176["rendercache.TemplateRenderMixin"]
2751680898["builtins.object"]
835538629["mkcontainer.MkContainer"]
1956333208["mkcontainer.MkContainerBase"]
1359323199["mknode.MkNode"]
1289759389 --> 1561279813
3160803176 --> 1289759389
2751680898 --> 3160803176
835538629 --> 1289759389
1956333208 --> 835538629
1359323199 --> 1956333208
2751680898 --> 1359323199
NodeFile
/home/runner/work/mknodes/mknodes/src/mknodes/templatenodes/mkconfigsetting/metadata.toml
[metadata]
name = "MkConfigSetting"
icon = "mdi:library"
virtual_children = true
[requirements.extension.def_list]
[examples.yaml]
title = "YAML format"
jinja = """
{{ "path" | MkConfigSetting(mode="yaml",
setting={"plugins": {"mknodes": {"path": "path.to.module"}}},
description="Some **markdown** to describe the setting",
default="path.to.module")}}
"""
[examples.json]
title = "JSON format"
jinja = """
{{ "path" | MkConfigSetting(mode="json",
setting={"plugins": {"mknodes": {"path": "path.to.module"}}},
description="Some **markdown** to describe the setting",
default="path.to.module")}}
"""
[examples.toml]
title = "TOML format"
jinja = """
{{ "path" | MkConfigSetting(mode="toml",
setting={"plugins": {"mknodes": {"path": "path.to.module"}}},
description="Some **markdown** to describe the setting",
default="path.to.module")}}
"""
[output.markdown]
template = """
{{ node.title | md_style(bold=True, code=True) }}
: {% filter indent %}Default: `{{ node.default | repr }}`
{% if node.version_added %}
Version added: `{{ node.version_added }}`
{% endif %}
{% if node.optional is not none %}
Required: `{{ "yes" if node.required else "no" }}`
{% endif %}
{{ node.description }}
{% if node.setting is instance(dict) %}
{{ node.setting | serialize(node.mode) | MkCode(language=node.mode) }}
{% else %}
{{ node.setting | MkCode(language=node.mode) }}
{% endif %}
{% endfilter %}
"""
Code
mknodes.templatenodes.mkconfigsetting.MkConfigSetting
class MkConfigSetting(mktemplate.MkTemplate):
"""Node for describing a config setting."""
ICON = "material/library"
def __init__(
self,
title: str,
description: str,
*,
setting: dict[str, Any] | str | None = None,
default: str | int | None = None,
version_added: str | None = None,
optional: bool | None = None,
mode: superdict.MarkupTypeStr = "yaml",
**kwargs: Any,
) -> None:
"""Constructor.
Args:
title: Setting title
description: Setting description
setting: (Nested) json-like object representing the setting
default: Default setting value
version_added: Version added
optional: Whether setting is optional. (None hides the label)
mode: Markup language of settings file
kwargs: Keyword arguments passed to parent
"""
super().__init__("output/markdown/template", **kwargs)
self.title = title
self.setting = setting
self.default = default
self.version_added = version_added
self.description = description
self.optional = optional
self.mode = mode
Page info
Code for this page
mknodes.manual.nodes_section.create_section_for_nodes
def create_section_for_nodes(
nav: mk.MkNav,
klasses: Sequence[type[mk.MkNode]],
) -> mk.MkTable:
table = mk.MkTable(columns=["Node", "Docstrings", "Markdown extensions"])
for kls in klasses:
tpl = "classpage_custom.jinja"
page = mk.MkClassPage(kls, icon=kls.ICON, template_path=tpl, parent=nav, hide="toc")
nav += page
if kls.STATUS:
page.metadata.status = kls.STATUS
elif kls.JS_FILES:
page.metadata.status = "js"
elif kls.CSS:
page.metadata.status = "css"
page.created_by = create_section_for_nodes
link = mk.MkLink(page, kls.__name__, icon=kls.ICON)
extensions = ", ".join(f"`{i}`" for i in kls.REQUIRED_EXTENSIONS)
table.add_row((link, kls.__doc__, extensions))
return table
Resources
Resources(css=[],
markdown_extensions={'admonition': {},
'pymdownx.details': {},
'pymdownx.highlight': {'anchor_linenums': True,
'line_spans': '__span',
'pygments_lang_class': True},
'pymdownx.superfences': {'custom_fences': [{'class': 'mermaid',
'format': <function fence_code_format at 0x7d707a397060>,
'name': 'mermaid'}]},
'pymdownx.tabbed': {},
'tables': {}},
plugins=[Plugin('mkdocstrings')],
js=[],
assets=[],
packages=[])
Metadata
created:
source_filename: /home/runner/work/mknodes/mknodes/src/mknodes/manual/nodes_section.py
source_function: create_section_for_nodes
source_line_no: 93
hide:
- toc
icon: material/library
status: new
title: MkConfigSetting